/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biblio.persistencias;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "prestamo", catalog = "mydb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Prestamo.findAll", query = "SELECT p FROM Prestamo p"),
    @NamedQuery(name = "Prestamo.findByPrestId", query = "SELECT p FROM Prestamo p WHERE p.prestId = :prestId"),
    @NamedQuery(name = "Prestamo.findByPrestFecha", query = "SELECT p FROM Prestamo p WHERE p.prestFecha = :prestFecha"),
    @NamedQuery(name = "Prestamo.findByPrestFechaDev", query = "SELECT p FROM Prestamo p WHERE p.prestFechaDev = :prestFechaDev"),
    @NamedQuery(name = "Prestamo.findByPrestEstado", query = "SELECT p FROM Prestamo p WHERE p.prestEstado = :prestEstado")})
public class Prestamo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "prest_id")
    private Integer prestId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prest_fecha", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date prestFecha;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prest_fecha_dev", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date prestFechaDev;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prest_estado", nullable = false)
    private boolean prestEstado;
    @JoinColumn(name = "prest_id_eje", referencedColumnName = "eje_id", nullable = false)
    @ManyToOne(optional = false)
    private Ejemplar prestIdEje;
    @JoinColumn(name = "prest_id_tp", referencedColumnName = "tp_id", nullable = false)
    @ManyToOne(optional = false)
    private PrestamoTipo prestIdTp;
    @JoinColumn(name = "prest_id_solicitante", referencedColumnName = "sol_id", nullable = false)
    @ManyToOne(optional = false)
    private Solicitante prestIdSolicitante;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "multapIdPre")
    private MultaPrestamo multaPrestamo;

    public Prestamo() {
    }

    public Prestamo(Integer prestId) {
        this.prestId = prestId;
    }

    public Prestamo(Integer prestId, Date prestFecha, Date prestFechaDev, boolean prestEstado) {
        this.prestId = prestId;
        this.prestFecha = prestFecha;
        this.prestFechaDev = prestFechaDev;
        this.prestEstado = prestEstado;
    }

    public Integer getPrestId() {
        return prestId;
    }

    public void setPrestId(Integer prestId) {
        this.prestId = prestId;
    }

    public Date getPrestFecha() {
        return prestFecha;
    }

    public void setPrestFecha(Date prestFecha) {
        this.prestFecha = prestFecha;
    }

    public Date getPrestFechaDev() {
        return prestFechaDev;
    }

    public void setPrestFechaDev(Date prestFechaDev) {
        this.prestFechaDev = prestFechaDev;
    }

    public boolean getPrestEstado() {
        return prestEstado;
    }

    public void setPrestEstado(boolean prestEstado) {
        this.prestEstado = prestEstado;
    }

    public Ejemplar getPrestIdEje() {
        return prestIdEje;
    }

    public void setPrestIdEje(Ejemplar prestIdEje) {
        this.prestIdEje = prestIdEje;
    }

    public PrestamoTipo getPrestIdTp() {
        return prestIdTp;
    }

    public void setPrestIdTp(PrestamoTipo prestIdTp) {
        this.prestIdTp = prestIdTp;
    }

    public Solicitante getPrestIdSolicitante() {
        return prestIdSolicitante;
    }

    public void setPrestIdSolicitante(Solicitante prestIdSolicitante) {
        this.prestIdSolicitante = prestIdSolicitante;
    }

    public MultaPrestamo getMultaPrestamo() {
        return multaPrestamo;
    }

    public void setMultaPrestamo(MultaPrestamo multaPrestamo) {
        this.multaPrestamo = multaPrestamo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prestId != null ? prestId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Prestamo)) {
            return false;
        }
        Prestamo other = (Prestamo) object;
        if ((this.prestId == null && other.prestId != null) || (this.prestId != null && !this.prestId.equals(other.prestId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return prestId.toString();
    }
    
}
